*************************************************************
*** Standardize

* Lowercase and replace ä etc.
foreach var in  Vorname Nachname {
	replace `var' = lower(`var')
	replace `var' = subinstr(`var', "ä", "ae", .)
	replace `var' = subinstr(`var', "ö", "oe", .)
	replace `var' = subinstr(`var', "Ö", "oe", .)
	replace `var' = subinstr(`var', "ü", "ue", .)
	replace `var' = subinstr(`var', "Ü", "ue", .)
	replace `var' = subinstr(`var', "ê", "e", .)
	replace `var' = subinstr(`var', "é", "e", .)
	replace `var' = subinstr(`var', "è", "e", .)
	replace `var' = subinstr(`var', "ì", "i", .)
	replace `var' = subinstr(`var', "í", "i", .)
	replace `var' = subinstr(`var', "î", "i", .)
	replace `var' = subinstr(`var', "ô", "o", .)
	replace `var' = subinstr(`var', "Ô", "o", .)
	replace `var' = subinstr(`var', "ó", "o", .)
	replace `var' = subinstr(`var', "Ó", "o", .)
	replace `var' = subinstr(`var', "û", "u", .)
	replace `var' = subinstr(`var', "ç", "c", .)
	replace `var' = subinstr(`var', "ë", "e", .)
	replace `var' = subinstr(`var', "à", "a", .)
	replace `var' = subinstr(`var', "À", "a", .)
	replace `var' = subinstr(`var', "á", "a", .)
	replace `var' = subinstr(`var', "Á", "a", .)
	replace `var' = subinstr(`var', "â", "a", .)
	replace `var' = subinstr(`var', "Â", "a", .)
	replace `var' = subinstr(`var', "É", "e", .)
	
  
}


* Drop Name Additions
foreach var in  Vorname Nachname{
	replace `var'=subinstr(`var',"von ", "",.)
	replace `var'=subinstr(`var',"Di ", "",.)
	replace `var'=subinstr(`var',"De ", "",.)
	replace `var'=subinstr(`var',"Prof. ", "",.)
	replace `var'=subinstr(`var',"Dr. ", "",.)
	replace `var'=subinstr(`var',"med. ", "",.)
	replace `var'=subinstr(`var',"van den ", "",.)
	replace `var'=subinstr(`var',"de ", "",.)
	replace `var'=subinstr(`var',"der ", "",.)
	replace `var'=subinstr(`var',"phil. ", "",.)
	replace `var'=subinstr(`var',"jun.", "",.)
	replace `var'=subinstr(`var',"et.", "+",.)
	replace `var'=subinstr(`var'," et ", " + ",.)
	replace `var'=subinstr(`var',"vet. ", "",.)
	replace `var'=subinstr(`var'," - ", "-",.)
	replace `var'=subinstr(`var',"- ", "-",.)
	replace `var'=subinstr(`var'," -", "-",.)
}

replace Vorname=trim(Vorname)
replace Nachname=trim(Nachname)

* Split Double Vorname

local var Vorname
replace `var'=subinstr(`var'," ", "@",.)
replace `var'=subinstr(`var',"-", "@",.)
split `var', p("@")
drop `var'
bys year ID Nachname Strasse HausNr PLZ: gen num = _n
reshape long `var', i(year ID Nachname Strasse HausNr PLZ num) j(temp)
drop if `var'==""
drop temp num


* Split Double Nachname

duplicates drop year ID Vorname Nachname Strasse HausNr PLZ, force
local var Nachname
replace `var'=subinstr(`var'," ", "@",.)
replace `var'=subinstr(`var',"-", "@",.)
split `var', p("@")
drop `var'
bys year ID Vorname Strasse HausNr PLZ: gen num = _n
reshape long `var', i(year ID Vorname Strasse HausNr PLZ num) j(temp)
drop if `var'==""
drop temp num


* Get Rid of Spaces before and after
replace Vorname = trim(Vorname)
replace Nachname = trim(Nachname)

gen Name = Vorname+" "+Nachname
drop Vorname Nachname 
replace Name=trim(Name)

	